﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading.Tasks;
using StyleMVVM.Logging;
using StyleMVVM.Utilities;
using l4n = log4net;

namespace StyleMVVM.log4net
{
	public class LogImpl : ILog
	{
		private l4n.ILog logger;

		public LogImpl(l4n.ILog realLog)
		{
			logger = realLog;
		}

		public Task<bool> Configure()
		{
			return TaskHelper.ReturnTask(true);
		}

		public LogLevel LoggingLevel { get; set; }

		public void Flush()
		{
		}

		public void Debug(string message)
		{
			logger.Debug(message);
		}

		public void Debug(string message, string supplemental)
		{
			logger.Debug(message);
		}

		public void Debug(string message, string supplemental, Exception exp)
		{
			logger.Debug(message, exp);
		}

		public void Info(string message)
		{
			logger.Info(message);
		}

		public void Info(string message, string supplemental)
		{
			logger.Info(message);
		}

		public void Info(string message, string supplemental, Exception exp)
		{
			logger.Info(message, exp);
		}

		public void Warn(string message)
		{
			logger.Warn(message);
		}

		public void Warn(string message, string supplemental)
		{
			logger.Warn(message);
		}

		public void Warn(string message, string supplemental, Exception exp)
		{
			logger.Warn(message);
		}

		public void Error(string message)
		{
			logger.Warn(message);
		}

		public void Error(string message, string supplemental)
		{
			logger.Warn(message);
		}

		public void Error(string message, string supplemental, Exception exp)
		{
			logger.Warn(message);
		}

		public void Fatal(string message)
		{
			logger.Warn(message);
		}

		public void Fatal(string message, string supplemental)
		{
			logger.Warn(message);
		}

		public void Fatal(string message, string supplemental, Exception exp)
		{
			logger.Warn(message);
		}

		public void Log(LogEntry logEntry)
		{
			switch (logEntry.Level)
			{
				case LogLevel.DEBUG:
					logger.Debug(logEntry.Message, logEntry.Exception);
					break;
				case LogLevel.INFO:
					logger.Info(logEntry.Message, logEntry.Exception);
					break;
				case LogLevel.WARN:
					logger.Warn(logEntry.Message, logEntry.Exception);
					break;
				case LogLevel.ERROR:
					logger.Error(logEntry.Message, logEntry.Exception);
					break;
				case LogLevel.FATAL:
					logger.Fatal(logEntry.Message, logEntry.Exception);
					break;
			}
		}
	}
}